#ifndef VPSQL_H
#define VPSQL_H

#include "progsql.h"
#include "GameDBInterface.h"



class VPokerOpts;
class VPokerSavedGame;
class ShueSave;
class VPHand;
class VPGameBase;
class VPConnection;

//
// All money values are in cents (100 == $1, 25 == $.25, 1 == $.01)
//
// IMPORTANT:  Access to this class is NOT thread-safe.  That's handled at
//			   the next level up (with calls to lock()/unlock()).
//


// kharmon.  03-22-06.  #10515.  Reorganized as part of adding 7 stud poker.
class VPokerSQL : public GameDBInterface
{
	public:       
		VPokerSQL(VPConnection *pConn, ProgressiveTrackSQL *pTracker, Info *pInfo);

		int32	trackNewGame(int32 bet, VPHand* dealt, VPokerSavedGame* saved, int32 *balance);
		bool8	trackDraw(VPHand*, int32 payout, int32 paytype, bool8 dblUpActive, int32* balance);
		bool8	trackDoubleUpDeny(int32 payout, int32* balance);
		bool8	trackDoubleUpDeal(int32 round, uint8 dealt, ShueSave*, int32* balance);
		bool8	trackDoubleUpDraw(int32 round, uint8 drawn, int32 winResult, int32 payout, int32* balance);
		bool8	trackNewSubGame();
		bool8	trackGetSubGame();

        bool8   processSavedGame(VPGameBase **ppGame, int32* err);


		int32 getOptions(VPokerOpts*, uint8 machId, int32 creditValue);

		int32 getPlayerLimits(const PID&, int32 gameId, uint8 machId,
			int32* compFactor);

		int32 createGame(
			int32 casinoId, const PID&, VPokerGameID, uint8 machineID,
			bool8 forMoney, SESSIONID, int32 compFactor,
			int32 bet, int32 numDealt, uint8* dealt,
			int32 creditValue, VPokerSavedGame*,
			int32 *balance, int32* comp);

		int32 draw(
			int32 casinoId, const PID&, VPokerGameID, uint8 machineID,
			bool8 forMoney, int32 creditValue,
			int32 numDrawn, uint8* drawn,
			int32 payout, int32 paytype,
			bool8 dblUpActive,
			int32* balance, int32* comp);

		int32 doubleUpDeny(
			int32 casinoId, const PID&, VPokerGameID, uint8 machineID,
			bool8 forMoney, int32 creditValue,
			int32 payout,
			int32* balance, int32* comp);

		int32 doubleUpDeal(
			int32 casinoId, const PID&, VPokerGameID, bool8 forMoney,
			int32 round, uint8 dealt, ShueSave*,
			int32* balance, int32* comp);

		int32 doubleUpDraw(
			int32 casinoId, const PID&, VPokerGameID, uint8 machineID,
			bool8 forMoney, int32 creditValue,
			int32 round, uint8 drawn, uint8 winResult, int32 payout,
			int32* balance, int32* comp);

		int32 hasSavedGame(const PID&, uint8 machineID, int32 creditValue,
			bool8 forMoney, VPokerGameID, VPokerSavedGame*, bool8* exists);

		int32 setSubGameData(VPokerGameID, uint8 index, uint8 data);
		bool8 getSubGameData(VPokerGameID, uint8 index, uint8* data);

    protected:

        VPConnection        *m_pConn; 

        ProgressiveTrackSQL *m_pTracker;

        Info                *m_pInfo;

};



#endif
